
/*
 * Copyright (C) 2011 Vinu K.N
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */



package org.domainmath.gui.pkg;



import javax.swing.JOptionPane;
import org.domainmath.gui.MainFrame;


/**
 *
 * @author Vinu K.N
 */
public class ReBuildDlg extends javax.swing.JDialog {
   
    private final MainFrame frame;
    private final String pkg_name;

    /** Creates new form UnInstallDlg */
    public ReBuildDlg(MainFrame frame, boolean modal,String pkg_name) {
        super(frame, modal);
        this.frame= frame;
        this.pkg_name=pkg_name;
        initComponents();     
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        reBuildButton = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        BuildCombo = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Rebuild Package");
        setName("UnInstdialog"); // NOI18N

        reBuildButton.setText("Rebuild");
        reBuildButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reBuildButtonActionPerformed(evt);
            }
        });

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });

        BuildCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-auto", "-noauto" }));

        jLabel1.setText("Options");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(reBuildButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cancelButton))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(36, 36, 36)
                        .addComponent(BuildCombo, 0, 348, Short.MAX_VALUE)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cancelButton, reBuildButton});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(BuildCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 169, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancelButton)
                    .addComponent(reBuildButton))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
       dispose();
    }//GEN-LAST:event_cancelButtonActionPerformed

    private void reBuildButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reBuildButtonActionPerformed
        try {
        
                       String pkg = pkg_name;

                       String comd ="pkg rebuild "+BuildCombo.getSelectedItem().toString()+" "+pkg;
                  MainFrame.octavePanel.evaluate(comd+";");
    
        }
        catch(Exception e) {
             JOptionPane.showMessageDialog(frame,"Package not selected","Error",JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_reBuildButtonActionPerformed

   
    /**
    * @param args the command line arguments
    */
   
 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox BuildCombo;
    private javax.swing.JButton cancelButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton reBuildButton;
    // End of variables declaration//GEN-END:variables

}
